Overview#
This notebook gives a general overview of the features included in the dataset.
Show imports
%load_ext autoreload
%autoreload 2
import os
import dimcat as dc
import pandas as pd
import plotly.express as px
from dimcat import filters, plotting
from IPython.display import display
import utils
RESULTS_PATH = os.path.abspath(os.path.join(utils.OUTPUT_FOLDER, "overview"))
os.makedirs(RESULTS_PATH, exist_ok=True)
def make_output_path(
filename: str,
extension=None,
path=RESULTS_PATH,
) -> str:
return utils.make_output_path(filename=filename, extension=extension, path=path)
def save_figure_as(
fig, filename, formats=("png", "pdf"), directory=RESULTS_PATH, **kwargs
):
if formats is not None:
for fmt in formats:
plotting.write_image(fig, filename, directory, format=fmt, **kwargs)
else:
plotting.write_image(fig, filename, directory, **kwargs)
Loading data
D = utils.get_dataset("bartok_bagatelles", corpus_release="v2.4")
package = D.inputs.get_package()
package_info = package._package.custom
git_tag = package_info.get("git_tag")
utils.print_heading("Data and software versions")
print("Béla Bartók – 14 Bagatelles, Op. 6 version v2.4")
print(f"Datapackage '{package.package_name}' @ {git_tag}")
print(f"dimcat version {dc.__version__}\n")
D
Data and software versions
--------------------------
Béla Bartók – 14 Bagatelles, Op. 6 version v2.4
Datapackage 'bartok_bagatelles' @ v2.4
dimcat version 3.4.0
Dataset
=======
{'inputs': {'basepath': None,
'packages': {'bartok_bagatelles': ["'bartok_bagatelles.measures' (MuseScoreFacetName.MuseScoreMeasures)",
"'bartok_bagatelles.notes' (MuseScoreFacetName.MuseScoreNotes)",
"'bartok_bagatelles.expanded' (MuseScoreFacetName.MuseScoreHarmonies)",
"'bartok_bagatelles.chords' (MuseScoreFacetName.MuseScoreChords)",
"'bartok_bagatelles.metadata' (FeatureName.Metadata)"]}},
'outputs': {'basepath': None, 'packages': {}},
'pipeline': []}
filtered_D = filters.HasHarmonyLabelsFilter(keep_values=[True]).process(D)
all_metadata = filtered_D.get_metadata()
assert len(all_metadata) > 0, "No pieces selected for analysis."
all_metadata
| TimeSig | KeySig | last_mc | last_mn | length_qb | last_mc_unfolded | last_mn_unfolded | length_qb_unfolded | all_notes_qb | n_onsets | ... | imslp | musicbrainz | typesetter | viaf | wikidata | P86 (composer) | staff_1_instrument | staff_1_ambitus | staff_2_instrument | staff_2_ambitus | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| corpus | piece | |||||||||||||||||||||
| bartok_bagatelles | op06n01 | {1: '4/4'} | {1: 4} | 18 | 18 | 72.00 | 18 | 18 | 72.00 | 121.50 | 135 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 47-78 (B2-F#5) | Piano | 43-72 (G2-C5) |
| op06n02 | {1: '2/2', 10: '3/2', 11: '2/2', 17: '3/2', 18... | {1: 0} | 30 | 30 | 124.00 | 30 | 30 | 124.00 | 298.50 | 493 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 44-84 (Ab2-C6) | Piano | 25-76 (Db1-E5) | |
| op06n03 | {1: '3/4'} | {1: 0} | 24 | 24 | 72.00 | 24 | 24 | 72.00 | 136.50 | 383 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 67-71 (G4-B4) | Piano | 57-73 (A3-C#5) | |
| op06n04 | {1: '3/4'} | {1: 0} | 12 | 12 | 36.00 | 12 | 12 | 36.00 | 189.50 | 233 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 53-74 (F3-D5) | Piano | 38-65 (D2-F4) | |
| op06n05 | {1: '2/4'} | {1: 0} | 90 | 90 | 180.00 | 90 | 90 | 180.00 | 810.00 | 1443 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 55-89 (G3-F6) | Piano | 41-69 (F2-A4) | |
| op06n06 | {1: '2/2'} | {1: 0} | 25 | 25 | 100.00 | 25 | 25 | 100.00 | 263.00 | 154 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 59-79 (B3-G5) | Piano | 39-62 (D#2-D4) | |
| op06n07 | {1: '3/4', 3: '2/4'} | {1: 0} | 118 | 118 | 238.00 | 118 | 118 | 238.00 | 553.38 | 955 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 35-88 (B1-E6) | Piano | 27-80 (D#1-G#5) | |
| op06n08 | {1: '2/4', 18: '3/4', 19: '2/4', 20: '3/4', 23... | {1: 0} | 32 | 32 | 69.00 | 32 | 32 | 69.00 | 199.50 | 317 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 55-87 (G3-D#6) | Piano | 39-84 (Eb2-C6) | |
| op06n09 | {1: '3/4'} | {1: 0} | 70 | 70 | 239.00 | 70 | 70 | 239.00 | 334.00 | 624 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 50-95 (D3-B6) | Piano | 27-80 (Eb1-G#5) | |
| op06n10 | {1: '2/2', 8: '1/2', 9: '2/2', 44: '3/2', 45: ... | {1: 0} | 102 | 102 | 406.00 | 102 | 102 | 406.00 | 1304.42 | 1686 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 31-95 (G1-B6) | Piano | 24-79 (C1-G5) | |
| op06n11 | {1: '2/4'} | {1: 0} | 87 | 87 | 174.00 | 87 | 87 | 174.00 | 541.75 | 672 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 50-91 (D3-G6) | Piano | 31-69 (G1-A4) | |
| op06n12 | {1: '6/8', 3: '5/8', 4: '3/8', 6: '9/8', 8: '3... | {1: 0} | 44 | 44 | 164.94 | 44 | 44 | 164.94 | 475.28 | 655 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 39-94 (Eb2-A#6) | Piano | 33-75 (A1-Eb5) | |
| op06n13 | {1: '4/4'} | {1: 0} | 26 | 26 | 104.00 | 26 | 26 | 104.00 | 279.50 | 422 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 49-85 (Db3-Db6) | Piano | 30-58 (Gb1-Bb3) | |
| op06n14 | {1: '3/8', 17: '3/4', 18: '3/8'} | {1: 0} | 218 | 218 | 328.50 | 218 | 218 | 328.50 | 694.50 | 1297 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 46-93 (Bb2-A6) | Piano | 26-93 (D1-A6) |
14 rows × 54 columns
mean_composition_years = utils.corpus_mean_composition_years(all_metadata)
chronological_order = mean_composition_years.index.to_list()
corpus_colors = dict(zip(chronological_order, utils.CORPUS_COLOR_SCALE))
corpus_names = {
corp: utils.get_corpus_display_name(corp) for corp in chronological_order
}
chronological_corpus_names = list(corpus_names.values())
corpus_name_colors = {
corpus_names[corp]: color for corp, color in corpus_colors.items()
}
mean_composition_years
corpus
bartok_bagatelles 1908.0
Name: mean_composition_year, dtype: float64
Composition dates#
This section relies on the dataset’s metadata.
valid_composed_start = pd.to_numeric(all_metadata.composed_start, errors="coerce")
valid_composed_end = pd.to_numeric(all_metadata.composed_end, errors="coerce")
print(
f"Composition dates range from {int(valid_composed_start.min())} {valid_composed_start.idxmin()} "
f"to {int(valid_composed_end.max())} {valid_composed_end.idxmax()}."
)
Composition dates range from 1908 ('bartok_bagatelles', 'op06n01') to 1908 ('bartok_bagatelles', 'op06n01').
Mean composition years per corpus#
def make_summary(metadata_df):
piece_is_annotated = metadata_df.label_count > 0
return metadata_df[piece_is_annotated].copy()
Show source
summary = make_summary(all_metadata)
bar_data = pd.concat(
[
mean_composition_years.rename("year"),
summary.groupby(level="corpus").size().rename("pieces"),
],
axis=1,
).reset_index()
N = len(summary)
fig = px.bar(
bar_data,
x="year",
y="pieces",
color="corpus",
color_discrete_map=corpus_colors,
title=f"Temporal coverage of the {N} annotated pieces in the Distant Listening Corpus",
)
fig.update_traces(width=5)
fig.update_layout(**utils.STD_LAYOUT)
fig.update_traces(width=5)
save_figure_as(fig, "pieces_timeline_bars")
fig.show()
summary
| TimeSig | KeySig | last_mc | last_mn | length_qb | last_mc_unfolded | last_mn_unfolded | length_qb_unfolded | all_notes_qb | n_onsets | ... | imslp | musicbrainz | typesetter | viaf | wikidata | P86 (composer) | staff_1_instrument | staff_1_ambitus | staff_2_instrument | staff_2_ambitus | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| corpus | piece | |||||||||||||||||||||
| bartok_bagatelles | op06n01 | {1: '4/4'} | {1: 4} | 18 | 18 | 72.00 | 18 | 18 | 72.00 | 121.50 | 135 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 47-78 (B2-F#5) | Piano | 43-72 (G2-C5) |
| op06n02 | {1: '2/2', 10: '3/2', 11: '2/2', 17: '3/2', 18... | {1: 0} | 30 | 30 | 124.00 | 30 | 30 | 124.00 | 298.50 | 493 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 44-84 (Ab2-C6) | Piano | 25-76 (Db1-E5) | |
| op06n03 | {1: '3/4'} | {1: 0} | 24 | 24 | 72.00 | 24 | 24 | 72.00 | 136.50 | 383 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 67-71 (G4-B4) | Piano | 57-73 (A3-C#5) | |
| op06n04 | {1: '3/4'} | {1: 0} | 12 | 12 | 36.00 | 12 | 12 | 36.00 | 189.50 | 233 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 53-74 (F3-D5) | Piano | 38-65 (D2-F4) | |
| op06n05 | {1: '2/4'} | {1: 0} | 90 | 90 | 180.00 | 90 | 90 | 180.00 | 810.00 | 1443 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 55-89 (G3-F6) | Piano | 41-69 (F2-A4) | |
| op06n06 | {1: '2/2'} | {1: 0} | 25 | 25 | 100.00 | 25 | 25 | 100.00 | 263.00 | 154 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 59-79 (B3-G5) | Piano | 39-62 (D#2-D4) | |
| op06n07 | {1: '3/4', 3: '2/4'} | {1: 0} | 118 | 118 | 238.00 | 118 | 118 | 238.00 | 553.38 | 955 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 35-88 (B1-E6) | Piano | 27-80 (D#1-G#5) | |
| op06n08 | {1: '2/4', 18: '3/4', 19: '2/4', 20: '3/4', 23... | {1: 0} | 32 | 32 | 69.00 | 32 | 32 | 69.00 | 199.50 | 317 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 55-87 (G3-D#6) | Piano | 39-84 (Eb2-C6) | |
| op06n09 | {1: '3/4'} | {1: 0} | 70 | 70 | 239.00 | 70 | 70 | 239.00 | 334.00 | 624 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 50-95 (D3-B6) | Piano | 27-80 (Eb1-G#5) | |
| op06n10 | {1: '2/2', 8: '1/2', 9: '2/2', 44: '3/2', 45: ... | {1: 0} | 102 | 102 | 406.00 | 102 | 102 | 406.00 | 1304.42 | 1686 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 31-95 (G1-B6) | Piano | 24-79 (C1-G5) | |
| op06n11 | {1: '2/4'} | {1: 0} | 87 | 87 | 174.00 | 87 | 87 | 174.00 | 541.75 | 672 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 50-91 (D3-G6) | Piano | 31-69 (G1-A4) | |
| op06n12 | {1: '6/8', 3: '5/8', 4: '3/8', 6: '9/8', 8: '3... | {1: 0} | 44 | 44 | 164.94 | 44 | 44 | 164.94 | 475.28 | 655 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 39-94 (Eb2-A#6) | Piano | 33-75 (A1-Eb5) | |
| op06n13 | {1: '4/4'} | {1: 0} | 26 | 26 | 104.00 | 26 | 26 | 104.00 | 279.50 | 422 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 49-85 (Db3-Db6) | Piano | 30-58 (Gb1-Bb3) | |
| op06n14 | {1: '3/8', 17: '3/4', 18: '3/8'} | {1: 0} | 218 | 218 | 328.50 | 218 | 218 | 328.50 | 694.50 | 1297 | ... | https://imslp.org/wiki/14_Bagatelles%2C_Op.6_(... | https://musicbrainz.org/work/38dfe04b-4f04-4c3... | Tatyana Tuchynska | https://viaf.org/viaf/183691259/#Barto%CC%81k,... | https://www.wikidata.org/wiki/Q790972 | Q83326 | Piano | 46-93 (Bb2-A6) | Piano | 26-93 (D1-A6) |
14 rows × 54 columns
Composition years histogram#
Show source
hist_data = summary.reset_index()
hist_data.corpus = hist_data.corpus.map(corpus_names)
fig = px.histogram(
hist_data,
x="composed_end",
color="corpus",
labels=dict(
composed_end="decade",
count="pieces",
),
color_discrete_map=corpus_name_colors,
title=f"Temporal coverage of the {N} annotated pieces in the Distant Listening Corpus",
)
fig.update_traces(xbins=dict(size=10))
fig.update_layout(**utils.STD_LAYOUT)
fig.update_legends(font=dict(size=16))
save_figure_as(fig, "pieces_timeline_histogram", height=1250)
fig.show()
Dimensions#
Overview#
def make_overview_table(groupby, group_name="pieces"):
n_groups = groupby.size().rename(group_name)
absolute_numbers = dict(
measures=groupby.last_mn.sum(),
length=groupby.length_qb.sum(),
notes=groupby.n_onsets.sum(),
labels=groupby.label_count.sum(),
)
absolute = pd.DataFrame.from_dict(absolute_numbers)
absolute = pd.concat([n_groups, absolute], axis=1)
sum_row = pd.DataFrame(absolute.sum(), columns=["sum"]).T
absolute = pd.concat([absolute, sum_row])
return absolute
absolute = make_overview_table(summary.groupby("workTitle"))
# print(absolute.astype(int).to_markdown())
absolute.astype(int)
| pieces | measures | length | notes | labels | |
|---|---|---|---|---|---|
| 14 Bagatelles | 14 | 896 | 2307 | 9469 | 1191 |
| sum | 14 | 896 | 2307 | 9469 | 1191 |
def summarize_dataset(D):
all_metadata = D.get_metadata()
summary = make_summary(all_metadata)
return make_overview_table(summary.groupby(level=0))
corpus_summary = summarize_dataset(D)
print(corpus_summary.astype(int).to_markdown())
| | pieces | measures | length | notes | labels |
|:------------------|---------:|-----------:|---------:|--------:|---------:|
| bartok_bagatelles | 14 | 896 | 2307 | 9469 | 1191 |
| sum | 14 | 896 | 2307 | 9469 | 1191 |
Measures#
all_measures = D.get_feature("measures")
print(
f"{len(all_measures.index)} measures over {len(all_measures.groupby(level=[0,1]))} files."
)
all_measures.head()
896 measures over 14 files.
| mc | mn | quarterbeats | duration_qb | keysig | timesig | act_dur | mc_offset | numbering_offset | dont_count | barline | breaks | repeats | next | |||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| corpus | piece | i | ||||||||||||||
| bartok_bagatelles | op06n01 | 0 | 1 | 1 | 0 | 4.0 | 4 | 4/4 | 1 | 0 | <NA> | <NA> | <NA> | <NA> | firstMeasure | (2,) |
| 1 | 2 | 2 | 4 | 4.0 | 4 | 4/4 | 1 | 0 | <NA> | <NA> | <NA> | <NA> | <NA> | (3,) | ||
| 2 | 3 | 3 | 8 | 4.0 | 4 | 4/4 | 1 | 0 | <NA> | <NA> | <NA> | <NA> | <NA> | (4,) | ||
| 3 | 4 | 4 | 12 | 4.0 | 4 | 4/4 | 1 | 0 | <NA> | <NA> | <NA> | line | <NA> | (5,) | ||
| 4 | 5 | 5 | 16 | 4.0 | 4 | 4/4 | 1 | 0 | <NA> | <NA> | <NA> | <NA> | <NA> | (6,) |
all_measures.get_default_analysis().plot_grouped()
Harmony labels#
All symbols, independent of the local key (the mode of which changes their semantics).
try:
all_annotations = D.get_feature("harmonylabels").df
except Exception:
all_annotations = pd.DataFrame()
n_annotations = len(all_annotations.index)
includes_annotations = n_annotations > 0
if includes_annotations:
display(all_annotations.head())
print(f"Concatenated annotation tables contains {all_annotations.shape[0]} rows.")
no_chord = all_annotations.root.isna()
if no_chord.sum() > 0:
print(
f"{no_chord.sum()} of them are not chords. Their values are:"
f" {all_annotations.label[no_chord].value_counts(dropna=False).to_dict()}"
)
all_chords = all_annotations[~no_chord].copy()
print(
f"Dataset contains {all_chords.shape[0]} tokens and {len(all_chords.chord.unique())} types over "
f"{len(all_chords.groupby(level=[0,1]))} documents."
)
all_annotations["corpus_name"] = all_annotations.index.get_level_values(0).map(
utils.get_corpus_display_name
)
all_chords["corpus_name"] = all_chords.index.get_level_values(0).map(
utils.get_corpus_display_name
)
else:
print("Dataset contains no annotations.")
| mc | mn | quarterbeats | quarterbeats_all_endings | duration_qb | mc_onset | mn_onset | timesig | staff | voice | ... | numeral_or_applied_to_numeral | intervals_over_bass | intervals_over_root | scale_degrees | scale_degrees_and_mode | scale_degrees_major | scale_degrees_minor | globalkey | localkey | chord | |||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| corpus | piece | i | |||||||||||||||||||||
| bartok_bagatelles | op06n01 | 0 | 1 | 1 | 0 | 0 | 8.0 | 0 | 0 | 4/4 | 2 | 1 | ... | i | (m3, d5) | (m3, d5) | (1, 3, b5) | (1, 3, b5), minor | (1, b3, b5) | (1, 3, b5) | c# | i | i(b5) |
| 1 | 3 | 3 | 8 | 8 | 4.0 | 0 | 0 | 4/4 | 2 | 1 | ... | V | (m2, m6) | (M3, P4) | (#7, 1, 5) | (#7, 1, 5), minor | (7, 1, 5) | (#7, 1, 5) | c# | i | V6(^4) | ||
| 2 | 4 | 4 | 12 | 12 | 4.0 | 0 | 0 | 4/4 | 2 | 1 | ... | i | (m3, d5) | (m3, d5) | (1, 3, b5) | (1, 3, b5), minor | (1, b3, b5) | (1, 3, b5) | c# | i | i(b5) | ||
| 3 | 5 | 5 | 16 | 16 | 4.0 | 0 | 0 | 4/4 | 2 | 1 | ... | V | (m3, d5, m6) | (M3, P5, m7) | (#7, 2, 4, 5) | (#7, 2, 4, 5), minor | (7, 2, 4, 5) | (#7, 2, 4, 5) | c# | i | V65 | ||
| 4 | 6 | 6 | 20 | 20 | 2.0 | 0 | 0 | 4/4 | 2 | 1 | ... | biv | (m3, P5) | (m3, P5) | (b4, b6, b1) | (b4, b6, b1), minor | (b4, bb6, b1) | (b4, b6, b1) | c# | i | biv(+b4) |
5 rows × 52 columns
Concatenated annotation tables contains 1175 rows.
Dataset contains 1175 tokens and 709 types over 14 documents.